home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Subject: Re: prefix vs. postfix
- X-Nntp-Posting-Host: golden.ripco.com
- Message-ID: <DKovAI.G26@rci.ripco.com>
- Sender: usenet@rci.ripco.com (Net News Admin)
- Organization: Ripco Internet BBS Chicago
- Date: Fri, 5 Jan 1996 03:35:05 GMT
- X-Ident-Sender: mambuhl
-
- scicom@globalcom.net (stephen j beaver) in
- <4cf35v$7il@head.globalcom.net> wrote:
-
- >I thought that:
-
- >for(i=0;i<10;i++)
- > {
- > loopbody(i):
- > }
-
- >Increments i after the loop so that the first value passed to loopbody() is zer
- >, whereas:
-
- >for(i=0;i<10;++i)
- > {
- > loopbody();
- > }
-
- >increments i before the loop body so that the first value passedtp loopbody() i
- > 1 in this case.
-
- >No?
-
- NO! from ISO 6.6.5.3:
-
- "Escept for the behavior of a continue statement in the loop body,
- the statement
-
- for (expression-1;expression-2;expression-3) statement
-
- and the sequence of statements
-
- expression-1;
- while(expression-2) {
- statement
- expression-3;
-
- }
-
- are equivalent."
-
-
- Notice that expression-3 does not move around depending on what it is.
- (Why would you think it did?)
-
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-